﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Windows.Forms;

//using DotSpatial.Controls;
//using DotSpatial.Symbology;
//using DotSpatial.Data;
//using DotSpatial.Topology;

//using System.Drawing;

//using Point=System.Drawing .Point;


//namespace HAGISV2
//{







//    /// <summary>
//    /// 小刘写
//    /// </summary>
//    public class HGMSSelectMF : HMapFunction
//    {

//        # region 需求分析

//        // 1 框选和点选统一，都是复选
//        // 2 端点是指图形的首尾点。顶点则是非端点。
//        // 3 端点选择和顶点选择是分开状态，哪怕一个端点和一个顶点重合，在各自的选择模式下选各自的。
//        // 4 在全选模式下,框选和点选是两种点都选，且是优先选，再选线，最后选面。（主要用于多边形线转多边形的情况）
//        // 5 右键菜单设置坐标时，如果在同一位置选择了n个点（可同时包括端点和顶点），是可以设置的。如果同时选择了不同位置的端点和顶点，则是不可设置的。
//        //   同一位置时判断可设置坐标后，再判断是顶点还是端点，端点具有优先级
//        // 6 多边形线转换多边形后，将多边形线切成两条再合并，如何与所转的多边形进行对应？？？？？同理，当给一个多边形线插入顶点后如何与多边形进行对应？？？


//        # endregion
        

//        public HGMSSelectMF(IMap map)
//            : base(map)
//        {
//        }

//        //这个方法既有点选又有框选
//        //


//        # region 选择机制字段

//        private HSelectMode _selectMode = HSelectMode.None;

//        # endregion

//        # region 选择机制设置

//        /// <summary>
//        /// 设置选择方式
//        /// </summary>
//        /// <param name="mode"></param>
//        public void SetSelectMode(HSelectMode mode)
//        {
//            this._selectMode = mode;
//        }


//        # endregion



//        //public List<IFeatureLayer> layerLst = new List<IFeatureLayer>();

//        private List<IFeatureLayer> layerLst
//        {
//            get
//            {
//                if (this.InteractiveSystem.CurrentLayer == null)
//                {
//                    return new List<IFeatureLayer>();
//                }
//                VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//                if (layer == null)
//                {
//                    return new List<IFeatureLayer>();
//                }

//                List<IFeatureLayer> layLst = new List<IFeatureLayer>();

//                DotSpatial.Symbology.IFeatureLayer ptFeatureLayer = layer.PtLayer as DotSpatial.Symbology.IFeatureLayer;
//                if (ptFeatureLayer != null)
//                {
//                    layLst.Add(ptFeatureLayer);
//                }

//                DotSpatial.Symbology.IFeatureLayer lnFeatureLayer = layer.LnLayer as DotSpatial.Symbology.IFeatureLayer;
//                if (lnFeatureLayer != null)
//                {
//                    layLst.Add(lnFeatureLayer);
//                }

//                DotSpatial.Symbology.IFeatureLayer polyFeatureLayer = layer.PyLayer as DotSpatial.Symbology.IFeatureLayer;
//                if (polyFeatureLayer != null)
//                {
//                    layLst.Add(polyFeatureLayer);
//                }

//                return layLst;

//            }
//        }

//        # region 暴露给外部只读属性

//        private List<IFeature> _selectedFeatures = null;

//        /// <summary>
//        /// 所选的图形，（每个图形只包含一次）
//        /// </summary>
//        //public List<IFeature> _selectedFeatures
//        //{
//        //    get { return (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedFeatures; }
//        //    set { this._selectedFeatures = value; }
//        //}

//        private Dictionary<IFeature, List<List<int>>> _selectedVertexs = null;  //顶点

//        /// <summary>
//        /// 所选的节点
//        /// </summary>
//        public Dictionary<IFeature, List<List<int>>> SelectedVertexs
//        {
//            get { return this._selectedVertexs; }
//        }

//        private Dictionary<IFeature, List<List<int>>> _selectedNodes = null;   //节点

//        /// <summary>
//        /// 所选的端点
//        /// </summary>
//        public Dictionary<IFeature, List<List<int>>> SelectedNodes
//        {
//            get { return this._selectedNodes; }
//        }

//        private List<IFeature> _selectedLines = null;

//        /// <summary>
//        /// 所选的线
//        /// </summary>
//        public List<IFeature> SelectedLines
//        {
//            get { return this._selectedLines; }
//        }

//        private List<IFeature> _selectedPolygons = null;

//        /// <summary>
//        /// 所选的面
//        /// </summary>
//        public List<IFeature> SelectedPolygons
//        {
//            get { return this._selectedPolygons; }
//        }

//        private CONCEPTLAYERRIGHTMENU _type;

//        /// <summary>
//        /// 哪种图形右键菜单
//        /// </summary>
//        public CONCEPTLAYERRIGHTMENU Type
//        {
//            get { return _type; }
//        }

//        # endregion

//        private Point _mousePosition;

//        //下面三个框选的字段，原以为只有点选呢……
//        private bool _selecting = false;  //用于MouseDown时……
//        private Point _startPosition;
//        private Point _endPosition;
//        private bool _isClick = false;  //是点选为true,是框选为false

//        private bool _selected = false; //这个字段主要是用来判断是否选择了，用于全选模式时优先选择是否选择了的判断

//        //复选字段
//        private bool _check = false;

//        //下面是关于移动的字段
//        private bool _dragging = false;
//        //private Coordinate _previousPoint = null;
//        private List<Coordinate> _nextPoints = null;
//        private Coordinate _dragPoint = null;
//        private List<IFeature> _dragFeatures = null;

//        # region 要暴露给外部的颜色可写属性

//        SolidBrush _nodeBrush = new SolidBrush(Color.Black);

//        public SolidBrush NodeBrush
//        {
//            get { return _nodeBrush; }
//            set { _nodeBrush = value; }
//        }

//        float _nodeSize = 5.0f;

//        public float NodeSize
//        {
//            get { return _nodeSize; }
//            set { _nodeSize = value; }
//        }


//        SolidBrush _pointBrush = new SolidBrush(Color.Red);

//        public SolidBrush PointBrush
//        {
//            get { return _pointBrush; }
//            set { _pointBrush = value; }
//        }

//        float _pointSize = 5.0f;

//        public float PointSize
//        {
//            get { return _pointSize; }
//            set { _pointSize = value; }
//        }




//        Pen _linePen = new Pen(Color.Red, 2.0f);

//        public Pen LinePen
//        {
//            get { return _linePen; }
//            set { _linePen = value; }
//        }

//        SolidBrush _polygonBrush = new SolidBrush(Color.Blue);

//        public SolidBrush PolygonBrush
//        {
//            get { return _polygonBrush; }
//            set { _polygonBrush = value; }
//        }


//        # endregion


//        ContextMenuStrip _context;


//        # region 继承的方法

//        protected override void OnActivate()
//        {
//            //this.layerLst = LayerLst;
//            this._selectedNodes = new Dictionary<IFeature, List<List<int>>>();
//            this._selectedVertexs = new Dictionary<IFeature, List<List<int>>>();
//            this._selectedFeatures = new List<IFeature>();
//            this._selectedLines = new List<IFeature>();
//            this._selectedPolygons = new List<IFeature>();

//            base.OnActivate();
//        }

//        protected override void OnDeactivate()
//        {
//            base.OnDeactivate();

//            this._selecting = false;
//            this._selectedFeatures = null;
//            this._selectedLines = null;
//            this._selectedPolygons = null;
//            this._selectedNodes = null;
//            this._selectedVertexs = null;
//            this._nextPoints = null;
//            this._dragging = false;
//            this._dragPoint = null;
//            this._dragFeatures = null;

//            //保注释  减少不必要的刷新
//            //Map.MapFrame.Initialize();
//            //Map.Invalidate();
//        }


//        protected override void OnDraw(MapDrawArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer .ViewMode !=FMAPVIEW.NORMAL) return;

//            if (this._standBy)
//            {
//                return;
//            }

//            this.DisplayFeature(e);

//            if (this._selecting == true) // && this._isClick == false)
//            {
//                e.Graphics.DrawRectangle(Pens.Black, new Rectangle(Math.Min(this._startPosition.X, this._mousePosition.X), Math.Min(this._startPosition.Y, this._mousePosition.Y),
//                    Math.Abs(this._mousePosition.X - this._startPosition.X), Math.Abs(this._startPosition.Y - this._mousePosition.Y)));
//                Map.MapFrame.Initialize();
//                Map.Invalidate();
//                //return;
//            }

//            if (this._dragging == true)
//            {
//                e.Graphics.FillEllipse(this._pointBrush, this._mousePosition.X - 5, this._mousePosition.Y - 5, 10.0f, 10.0f);

//                if (this._nextPoints != null && this._nextPoints.Count > 0)
//                {
//                    foreach (Coordinate c in this._nextPoints)
//                    {
//                        e.Graphics.DrawLine(this._linePen, e.GeoGraphics.ProjToPixel(c), this._mousePosition);
//                    }
//                }
//                Map.MapFrame.Initialize();
//                Map.Invalidate();
//                //return;
//            }

//            if (this._selectedNodes != null)
//            {
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                {
//                    List<Coordinate> coors = new List<Coordinate>();
//                    foreach (List<int> index in feature.Value)
//                    {
//                        if (index[0] == 0)
//                        {
//                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                        }
//                        else
//                        {
//                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                        }                        
//                    }
//                    foreach (Coordinate coor in coors)
//                    {
//                        Point pt = Map.ProjToPixel(coor);
//                        e.Graphics.FillEllipse(this._nodeBrush, pt.X - this._nodeSize, pt.Y - this._nodeSize, this._nodeSize * 2, this._nodeSize * 2);
//                    }

//                }
//            }

//            if (this._selectedVertexs != null)
//            {
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                {
//                    List<Coordinate> coors = new List<Coordinate>();
//                    foreach (List<int> index in feature.Value)
//                    {
//                        if (index[0] == 0)
//                        {
//                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                        }
//                        else
//                        {
//                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                        }
//                    }

//                    foreach (Coordinate coor in coors)
//                    {
//                        Point pt = Map.ProjToPixel(coor);
//                        e.Graphics.FillEllipse(this._pointBrush, pt.X - this._pointSize, pt.Y - this._pointSize, this._pointSize * 2, this._pointSize * 2);
//                    }
//                }
//            }

//            if (this._selectedLines != null)
//            {
//                foreach (IFeature line in this._selectedLines)
//                {
//                    List<Point> pts = new List<Point>();
//                    foreach (Coordinate coor in line.BasicGeometry.Coordinates)
//                    {
//                        pts.Add(Map.ProjToPixel(coor));
//                    }
//                    e.Graphics.DrawLines(this._linePen, pts.ToArray());
//                }
//            }

//            if (this._selectedPolygons != null)
//            {
//                foreach (IFeature polygon in this._selectedPolygons)
//                {
//                    //有洞的多边形的绘制思路
//                    //先将外围的点生成一个多边形，再生成GraphicsPath，最后生成Region
//                    //将内部的多个洞生成多个多边形，再生成多个GraphicsPath，最后生成一个Region
//                    //用大的Region减去（Exclude方法）小的Region,生成带洞的Region
//                    //添充Region

//                    List<Point> pts = new List<Point>();
//                    foreach (Coordinate coor in (polygon.BasicGeometry as Polygon).ExteriorRing.Coordinates)
//                    {
//                        pts.Add(Map.ProjToPixel(coor));
//                    }

//                    //有些多边形有洞
//                    List<List<Point>> holes = new List<List<Point>>();
//                    foreach (ILinearRing linearRing in (polygon.BasicGeometry as Polygon).Holes)
//                    {
//                        List<Point> hole = new List<Point>();
//                        foreach (Coordinate c in linearRing.Coordinates)
//                        {
//                            hole.Add(Map.ProjToPixel(c));
//                        }
//                        holes.Add(hole);
//                    }

//                    System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
//                    path.AddPolygon(pts.ToArray());
//                    Region region = new Region(path);

//                    System.Drawing.Drawing2D.GraphicsPath holePath = new System.Drawing.Drawing2D.GraphicsPath();
//                    foreach (List<Point> hole in holes)
//                    {
//                        holePath.AddPolygon(hole.ToArray());
//                    }
//                    Region holeRegion = new Region(holePath);

//                    region.Exclude(holeRegion);

//                    //e.Graphics.FillPolygon(this._polygonBrush, pts.ToArray());
//                    e.Graphics.FillRegion(this._polygonBrush, region);


//                }
//            }

//            base.OnDraw(e);

//        }


//        protected override void OnMouseDown(GeoMouseArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer.ViewMode != FMAPVIEW.NORMAL) return;

//            if (this._standBy)
//            {
//                return;
//            }

//            base.OnMouseDown(e);

//            if (e.Button != System.Windows.Forms.MouseButtons.Left)
//            {
//                return;
//            }

//            //鼠标位置
//            this._mousePosition = e.Location;

//            # region 添加顶点

//            if (this._selectMode == HSelectMode.InsertVertex)
//            {
//                this.InsertVertex(e.GeographicLocation);
//                return;
//            }

//            # endregion

//            # region 拖拽

//            if (this._selectedNodes != null && this._selectedNodes.Count > 0)
//            {
//                //鼠标作用范围
//                Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
//                IEnvelope env = Map.PixelToProj(mouseRect).ToEnvelope();
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                {
//                    List<Coordinate> coors = new List<Coordinate>();
//                    foreach (List<int> index in feature.Value)
//                    {
//                        if (index[0] == 0)
//                        {
//                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                        }
//                        else
//                        {
//                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                        }
//                    }
//                    foreach (Coordinate coor in coors)
//                    {
//                        if (env.Contains(coor) == true)
//                        {
//                            this._dragging = true;  //可移动
//                            this._dragPoint = coor;
//                            this.CheckForVertexDrag();  //确定哪些点跟要移动的点有关系
//                            Map.MapFrame.Initialize();
//                            Map.Invalidate();
//                            return;
//                        }
//                    }
//                }
//            }

//            if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//            {
//                //鼠标作用范围
//                Rectangle mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
//                IEnvelope env = Map.PixelToProj(mouseRect).ToEnvelope();
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                {
//                    List<Coordinate> coors = new List<Coordinate>();
//                    foreach (List<int> index in feature.Value)
//                    {
//                        if (index[0] == 0)
//                        {
//                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                        }
//                        else
//                        {
//                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                        }
//                    }

//                    foreach (Coordinate coor in coors)
//                    {
//                        if (env.Contains(coor) == true)
//                        {
//                            this._dragging = true;  //可移动
//                            this._dragPoint = coor;
//                            this.CheckForVertexDrag();  //确定哪些点跟要移动的点有关系
//                            Map.MapFrame.Initialize();
//                            Map.Invalidate();
//                            return;
//                        }
//                    }
//                }
//            }

//            # endregion


//            # region 选择设置

//            this._startPosition = e.Location;  //如果是框选，记下起始位置…
//            this._selecting = true;
//            if (this._check == false)
//            {
//                this._selectedNodes.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//                this._selectedVertexs.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//                this._selectedFeatures.Clear(); // = new List<IFeature>();
//                this._selectedLines.Clear(); // = new List<IFeature>();
//                this._selectedPolygons.Clear(); // = new List<IFeature>();
//            }

//            # endregion

//            Map.MapFrame.Initialize();
//            Map.Invalidate();

//        }


//        protected override void OnMouseMove(GeoMouseArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer.ViewMode != FMAPVIEW.NORMAL) return;

//            if (this._standBy)
//            {
//                return;
//            }

//            this._mousePosition = e.Location;

//            if (this._dragging)
//            {
//                //其实刷新应该写在这,但写在这很卡,就写在onDraw了
//                //Map.MapFrame.Initialize();
//                //Map.Invalidate();
//                return;
//            }
//            //在这里判断是点选还是框选
//            if (this._selecting)
//            {
//                this._isClick = false;
//            }


//            base.OnMouseMove(e);
//        }


//        protected override void OnMouseUp(GeoMouseArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer.ViewMode != FMAPVIEW.NORMAL) return;

//            if (this._standBy)
//            {
//                return;
//            }

//            base.OnMouseUp(e);

//            # region 右键菜单

//            if (e.Button == System.Windows.Forms.MouseButtons.Right)
//            {
          
//                //第一优先级是点（先端点再顶点），第二是线，第三是面（各种需求不清）
                
//                Rectangle mouseRect;
//                IEnvelope env;

//                //点选范围
//                mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
//                env = Map.PixelToProj(mouseRect).ToEnvelope();

//                # region 端点右键

//                if (this._selectedNodes != null && this._selectedNodes.Count > 0)
//                {
//                    //首先判断是否显示端点右键菜单
//                    bool isShowContex = false;
//                    foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                    {
//                        Coordinate c = new Coordinate();
//                        foreach (List<int> index in feature.Value)
//                        {
//                            if (index[0] == 0)
//                            {
//                                c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                            }
//                            else
//                            {
//                                c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                            }

//                            if (env.Contains(c))
//                            {
//                                isShowContex = true;
//                                break;
//                            }
//                        }
//                        if (isShowContex == true) break;
//                    }
//                    //如果显示端点右键菜单，再判断是否可设置坐标
//                    if (isShowContex == true)
//                    {
//                        bool isShowSetCoor = true;
//                        foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                        {
//                            Coordinate c = new Coordinate();
//                            foreach (List<int> index in feature.Value)
//                            {
//                                if (index[0] == 0)
//                                {
//                                    c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                                }
//                                else
//                                {
//                                    c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                                }

//                                if (env.Contains(c) == false)
//                                {
//                                    isShowSetCoor = false;
//                                    break;
//                                }
//                            }
//                            if (isShowSetCoor == false) break;
//                        }
//                        if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//                        {
//                            foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                            {
//                                Coordinate c = new Coordinate();
//                                foreach (List<int> index in feature.Value)
//                                {
//                                    if (index[0] == 0)
//                                    {
//                                        c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                                    }
//                                    else
//                                    {
//                                        c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                                    }

//                                    if (env.Contains(c) == false)
//                                    {
//                                        isShowSetCoor = false;
//                                        break;
//                                    }
//                                }
//                                if (isShowSetCoor == false) break;
//                            }
//                        }

//                        foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                        {
//                            //显示右键菜单
//                            if (feature.Key.FeatureType == FeatureType.Point)  //优先右键显示普通的点
//                            {
//                                this._type = CONCEPTLAYERRIGHTMENU.POINT;
//                                if (isShowSetCoor == true)
//                                {
//                                    (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = true;
//                                }
//                                else
//                                {
//                                    (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = false;
//                                }
//                                this._context = this.InteractiveSystem.GetConceptLayerRightClickMenu(CONCEPTLAYERRIGHTMENU.POINT);
//                                this._context.Show(InteractiveSystem.GisManager.CurrentMap, e.Location);

//                                return;
//                            }
//                        }
//                        //如果没有普通的点，再显示线或面上的端点
//                        this._type = CONCEPTLAYERRIGHTMENU.NODE;
//                        if (isShowSetCoor == true)
//                        {
//                            (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = true;
//                        }
//                        else
//                        {
//                            (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = false;
//                        }
//                        this._context = this.InteractiveSystem.GetConceptLayerRightClickMenu(CONCEPTLAYERRIGHTMENU.NODE);
//                        this._context.Show(InteractiveSystem.GisManager.CurrentMap, e.Location);

//                        return;
//                    }
//                }

//                # endregion

//                # region 顶点右键

//                if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//                {
//                     //首先判断是否显示顶点右键菜单
//                    bool isShowContex = false;
//                    foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                    {
//                        Coordinate c = new Coordinate();
//                        foreach (List<int> index in feature.Value)
//                        {
//                            if (index[0] == 0)
//                            {
//                                c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                            }
//                            else
//                            {
//                                c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                            }

//                            if (env.Contains(c))
//                            {
//                                isShowContex = true;
//                                break;
//                            }
//                        }
//                        if (isShowContex == true) break;
//                    }
//                    //如果显示顶点右键菜单，再判断是否可设置坐标
//                    if (isShowContex == true)
//                    {

//                        bool isShowSetCoor = true;
//                        foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                        {
//                            Coordinate c = new Coordinate();
//                            foreach (List<int> index in feature.Value)
//                            {
//                                if (index[0] == 0)
//                                {
//                                    c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                                }
//                                else
//                                {
//                                    c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                                }

//                                if (env.Contains(c) == false)
//                                {
//                                    isShowSetCoor = false;
//                                    break;
//                                }
//                            }
//                            if (isShowSetCoor == false) break;
//                        }

//                        if (this._selectedNodes != null && this._selectedNodes.Count > 0)
//                        {
//                            foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                            {
//                                Coordinate c = new Coordinate();
//                                foreach (List<int> index in feature.Value)
//                                {
//                                    if (index[0] == 0)
//                                    {
//                                        c = feature.Key.BasicGeometry.Coordinates[index[1]];
//                                    }
//                                    else
//                                    {
//                                        c = (feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]];
//                                    }

//                                    if (env.Contains(c) == false)
//                                    {
//                                        isShowSetCoor = false;
//                                        break;
//                                    }
//                                }
//                                if (isShowSetCoor == false) break;
//                            }
//                        }

//                        this._type = CONCEPTLAYERRIGHTMENU.VERTEX;
//                        if (isShowSetCoor == true)
//                        {
//                            (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = true;
//                        }
//                        else
//                        {
//                            (this.InteractiveSystem.CurrentLayer as VectorLayer).IsSetCoorEffective = false;
//                        }
//                        this._context = this.InteractiveSystem.GetConceptLayerRightClickMenu(CONCEPTLAYERRIGHTMENU.VERTEX);
//                        this._context.Show(InteractiveSystem.GisManager.CurrentMap, e.Location);

//                        return;
//                    }

//                }

//                # endregion

//                if (this._selectedLines != null)
//                {
//                    foreach (IFeature feature in this._selectedLines)
//                    {
//                        if (feature.FeatureType != FeatureType.Line) continue;
//                        if (feature.Intersects(env))
//                        {
//                            //显示右键菜单
//                            this._type = CONCEPTLAYERRIGHTMENU.LINE;
//                            this._context = this.InteractiveSystem.GetConceptLayerRightClickMenu(CONCEPTLAYERRIGHTMENU.LINE);
//                            this._context.Show(InteractiveSystem.GisManager.CurrentMap, e.Location);

//                            return;
//                        }
//                    }
//                }

//                if (this._selectedPolygons != null)
//                {
//                    foreach (IFeature feature in this._selectedPolygons)
//                    {
//                        if (feature.FeatureType != FeatureType.Polygon) continue;
//                        if (feature.Intersects(env))
//                        {
//                            //显示右键菜单
//                            this._type = CONCEPTLAYERRIGHTMENU.POLYGON;
//                            this._context = this.InteractiveSystem.GetConceptLayerRightClickMenu(CONCEPTLAYERRIGHTMENU.POLYGON);
//                            this._context.Show(InteractiveSystem.GisManager.CurrentMap, e.Location);

//                            return;
//                        }
//                    }
//                }
                
//                return;
//            }

//            # endregion


//            # region  图形改变事件

//            if (this._dragging == true)
//            {
//                this._dragging = false;
//                this._nextPoints = null;


//                Rectangle mouseRect;
//                IEnvelope env;

//                //点选范围
//                mouseRect = new Rectangle(this.Map.ProjToPixel(this._dragPoint).X - 3, this.Map.ProjToPixel(this._dragPoint).Y - 3, 6, 6);
//                env = Map.PixelToProj(mouseRect).ToEnvelope();

//                //=============================记录一下所选择的feature 和 coordinate的位置，以方便外围改变后从新查找一下再赋回来===========================//
//                //因为是引用传递，所以这里不做记录，下面也不需做重新赋值的操作


//                //=============================================================================================================================================//

//                //触发图形改变的事件            
//                foreach (IFeature _dragFeature in this._dragFeatures)
//                {
//                    List<Coordinate> coorLst = new List<Coordinate>();
//                    foreach (Coordinate coor in _dragFeature.BasicGeometry.Coordinates)
//                    {
//                        Coordinate c = new Coordinate(coor.X, coor.Y);
//                        coorLst.Add(c);
//                    }

//                    IFeature newFea = null;

//                    if (_dragFeature.FeatureType == FeatureType.Polygon)
//                    {
//                        coorLst = new List<Coordinate>();
//                        foreach (Coordinate coor in (_dragFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates)
//                        {
//                            Coordinate c = new Coordinate(coor.X, coor.Y);
//                            coorLst.Add(c);
//                        }
//                        List<LinearRing> holes = new List<LinearRing>();
//                        foreach (ILinearRing linearRing in (_dragFeature.BasicGeometry as Polygon).Holes)
//                        {
//                            List<Coordinate> hole = new List<Coordinate>();
//                            foreach (Coordinate coor in linearRing.Coordinates)
//                            {
//                                Coordinate c = new Coordinate(coor.X, coor.Y);
//                                hole.Add(c);
//                            }
//                            LinearRing linear = new LinearRing(hole.ToArray());
//                            holes.Add(linear);
//                        }


//                        Polygon polygon = new Polygon(new LinearRing(coorLst.ToArray()), holes.ToArray());
//                        newFea = new Feature(polygon);
//                    }
//                    else
//                    {
//                        if (_dragFeature.FeatureType == FeatureType.Line)
//                        {
//                            LineShape lineShp = layer.GetShape(_dragFeature.DataRow["id"].ToString()) as LineShape;                            

//                            //ILinearRing linear = _dragFeature.BasicGeometry as ILinearRing;
//                            //if (_dragFeature.BasicGeometry.Coordinates[0].X == _dragFeature.BasicGeometry.Coordinates[_dragFeature.BasicGeometry.Coordinates.Count - 1].X &&
//                            //   _dragFeature.BasicGeometry.Coordinates[0].Y == _dragFeature.BasicGeometry.Coordinates[_dragFeature.BasicGeometry.Coordinates.Count - 1].Y)
//                            if (lineShp.IsEnClosed)
//                            {
//                                ILinearRing linearRing = new LinearRing(coorLst);
//                                newFea = new Feature(linearRing);
//                            }
//                            else
//                            {
//                                newFea = new Feature(_dragFeature.FeatureType, coorLst.ToArray());  // this._selectedFeature.Clone() as IFeature;   // new Feature(this._selectedFeature.FeatureType, coorLst.ToArray());
//                            }
//                        }
//                        else
//                        {
//                            newFea = new Feature(_dragFeature.FeatureType, coorLst.ToArray());  // this._selectedFeature.Clone() as IFeature;   // new Feature(this._selectedFeature.FeatureType, coorLst.ToArray());
                           
//                        }


//                    }
//                    string featureId = _dragFeature.DataRow["id"].ToString();


//                    foreach (Coordinate coor in newFea.BasicGeometry.Coordinates)
//                    {

//                        if (env.Contains(coor))
//                        {
//                            coor.X = e.GeographicLocation.X;
//                            coor.Y = e.GeographicLocation.Y;
//                            //if (this._dragFeature.FeatureType == FeatureType.Point) //多边形首点和尾点相同
//                            //{
//                            //    break;
//                            //}
//                        }
//                    }


//                    string layerID = this.InteractiveSystem.CurrentLayer.Id;

//                    this.InteractiveSystem.HGMSAskEditShape(new HGMSSelectMFEventArgs(layerID, featureId, newFea as Feature,true));


//                    //=============================================================================================================================================//
//                    //因为是引用传递，不需做重新赋值的操作

//                    _dragFeature.UpdateEnvelope();  //更新操做应该是外部的事情，外部没做就我来做吧……
//                }

//                //字段重新赋值的操作
//                if (this._selectedNodes != null)
//                {
//                    //foreach (KeyValuePair<IFeature, List<Coordinate>> feature in this._selectedNodes)
//                    //{
//                    //    foreach (Coordinate coor in feature.Value)
//                    //    {
//                    //        if (env.Contains(coor))
//                    //        {
//                    //            coor.X = e.GeographicLocation.X;
//                    //            coor.Y = e.GeographicLocation.Y;
//                    //            //break;
//                    //        }
//                    //    }
//                    //}
//                }

//                if (this._selectedVertexs != null)
//                {
//                    //foreach (KeyValuePair<IFeature, List<Coordinate>> feature in this._selectedVertexs)
//                    //{
//                    //    foreach (Coordinate coor in feature.Value)
//                    //    {
//                    //        if (env.Contains(coor))
//                    //        {
//                    //            coor.X = e.GeographicLocation.X;
//                    //            coor.Y = e.GeographicLocation.Y;
//                    //            //break;
//                    //        }
//                    //    }
//                    //}
//                }



//                Map.MapFrame.Initialize();
//                Map.Invalidate();

//            }

//            # endregion


//            # region 开始选择

//            if (this._selecting == true)
//            {
//                this._endPosition = e.Location;  //如果是框选，记录下鼠标结束位置

//                this.SelectFeature();
//                //if (this._check == false)
//                //{
//                this._selecting = false;  //选择结束
//                //}
//                //选择结束，给VectorLayer赋值……
//                (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedFeatures = this._selectedFeatures;
//                (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedNodes = this._selectedNodes;
//                (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedVertexs = this._selectedVertexs;
//                (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedLines = this._selectedLines;
//                (this.InteractiveSystem.CurrentLayer as VectorLayer).SelectedPolygons = this._selectedPolygons;

//            }



//            # endregion

//        }


//        protected override void OnMouseWheel(GeoMouseArgs e)
//        {
//            if (this._standBy)
//            {
//                return;
//            }

//            base.OnMouseWheel(e);
//        }


//        protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer.ViewMode != FMAPVIEW.NORMAL) return;

//            if (this._standBy)
//            {
//                return;
//            }

//            if (e.KeyCode == System.Windows.Forms.Keys.ControlKey)
//            {
//                this._check = true;
//            }

//            if (e.KeyCode == System.Windows.Forms.Keys.Escape)
//            {
//                if (this._dragging)
//                {
//                    this._dragging = false;
//                    return;
//                }
//                if (this._selecting == true)
//                {
//                    this._selecting = false;
//                    return;
//                }
//            }

//            //按delete键
//            this.DeleteSelected(e);

//            base.OnKeyDown(e);
//        }


//        protected override void OnKeyUp(System.Windows.Forms.KeyEventArgs e)
//        {
//            VectorLayer layer = this.InteractiveSystem.CurrentLayer as VectorLayer;
//            if (layer == null) return;
//            if (layer.Visible == false || layer.ViewMode != FMAPVIEW.NORMAL) return;

//            if (e.KeyCode == System.Windows.Forms.Keys.ControlKey)
//            {
//                this._check = false;
//            }

//            base.OnKeyUp(e);
//        }

//        # endregion



//        # region 辅助方法:选择、删除、显示


//        /// <summary>
//        /// 图形的特殊显示
//        /// </summary>
//        /// <param name="e"></param>
//        private void DisplayFeature(MapDrawArgs e)
//        {
//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    if (feature.FeatureType == FeatureType.Point)
//                    {
//                        System.Drawing.Point pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[0]);
//                        e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 3, pt.Y - 3, 6, 6));
//                    }
//                    if (feature.FeatureType == FeatureType.Line)
//                    {
//                        System.Drawing.Point pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[0]);
//                        e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 3, pt.Y - 3, 6, 6));
//                        pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1]);
//                        e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 3, pt.Y - 3, 6, 6));

//                        if (this._selectMode == HSelectMode.Vertex || this ._selectMode==HSelectMode.InsertVertex || this._selectMode==HSelectMode.All)
//                        {
//                            for (int i = 1; i < feature.BasicGeometry.Coordinates.Count - 1; i++)
//                            {
//                                pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[i]);
//                                e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
//                            }
//                        }

//                    }
//                    if (feature.FeatureType == FeatureType.Polygon)
//                    {
//                        System.Drawing.Point pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[0]);
//                        e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 3, pt.Y - 3, 6, 6));
//                        if (this._selectMode == HSelectMode.Vertex)
//                        {
//                            for (int i = 1; i < feature.BasicGeometry.Coordinates.Count - 1; i++)
//                            {
//                                pt = Map.ProjToPixel(feature.BasicGeometry.Coordinates[i]);
//                                e.Graphics.FillRectangle(Brushes.Black, new Rectangle(pt.X - 2, pt.Y - 2, 4, 4));
//                            }
//                        }
//                    }
//                }
//            }
//        }


//        /// <summary>
//        /// 根据鼠标位置选择图形
//        /// </summary>
//        private void SelectFeature()
//        {
//            //this._selectedNodes = new List<Coordinate>();
//            //this._selectedVertexs = new List<Coordinate>();
//            //this._selectedFeatures = new List<IFeature>();
//            //this._selectedLines = new List<IFeature>();
//            //this._selectedPolygons = new List<IFeature>();

//            //判断是点选还是框选
//            if (this._startPosition.X == this._endPosition.X && this._startPosition.Y == this._endPosition.Y)
//            {
//                this._isClick = true;
//            }
//            //else
//            //{
//            //    this._isClick = false;
//            //}

//            //鼠标作用范围
//            Rectangle mouseRect;
//            IEnvelope env;

//            if (this._isClick == true)
//            {
//                //点选范围
//                mouseRect = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
//                env = Map.PixelToProj(mouseRect).ToEnvelope();
//            }
//            else
//            {
//                //框选范围
//                mouseRect = new Rectangle(Math.Min(this._startPosition.X, this._endPosition.X), Math.Min(this._startPosition.Y, this._endPosition.Y),
//                    Math.Abs(this._startPosition.X - this._endPosition.X), Math.Abs(this._startPosition.Y - this._endPosition.Y));
//                env = Map.PixelToProj(mouseRect).ToEnvelope();
//            }


//            //根据范围进行选择
//            switch (this._selectMode)
//            {
//                case HSelectMode.None:

//                    break;

//                case HSelectMode.All:

//                    //这里是根据状态的优先等级进行判断的
//                    this.SelectAll(env);

//                    break;
//                case HSelectMode.Node:  //选择节点

//                    this.SelectNode(env);

//                    break;
//                case HSelectMode.Vertex:  //选择顶点

//                    this.SelectVertex(env);

//                    break;
//                case HSelectMode.Line:  //选择线,包括: 1 线图形 2 面图形的轮廓线

//                    this.SelectLine(env);

//                    break;
//                case HSelectMode.Polygon:

//                    this.SelectPolygon(env);

//                    break;
//                case HSelectMode.Group:
//                    break;

//            }
//            this.Map.Invalidate();
//        }


//        private void SelectAll(IEnvelope env)
//        {
//            //现在是框选和点选 选择点（不管是端点还是顶点）统一，都是复选

//            if (this._isClick == true)  //点选情况下优先选点（不管是端点还是顶点），再选线，最后选面
//            {
//                this._selected = false;
//                this.SelectNode(env);
//                //if (this._selected == false) this.SelectVertex(env);
//                this.SelectVertex(env);
//                if (this._selected == false) this.SelectLine(env);
//                if (this._selected == false) this.SelectPolygon(env);

//            }
//            else //框选
//            {
            
//            this.SelectNode(env);
//            this.SelectVertex(env);
//            this.SelectLine(env);
//            this.SelectPolygon(env);
//            }
//        }


//        private void SelectNode(IEnvelope env)
//        {
//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    bool isIn = false;
//                    //多边形包括有洞的多边形
//                    switch (feature.FeatureType)
//                    {
//                        case FeatureType.Point:
//                            {
//                                if (env.Contains(feature.BasicGeometry.Coordinates[0]) == true)
//                                {
//                                    isIn = true;
//                                    if (this._selectedNodes.Keys.Contains(feature) == false)
//                                    {
//                                        this._selectedNodes.Add(feature, new List<List<int>>());
//                                    }
//                                    List<int> index = new List<int>();
//                                    index.Add(0);
//                                    index.Add(0);
//                                    this._selectedNodes[feature].Add(index);
//                                    this._selected = true;
//                                }
//                                break;
//                            }
//                        case FeatureType.Line:
//                            {
//                                if (env.Contains(feature.BasicGeometry.Coordinates[0]) == true)
//                                {
//                                    isIn = true;
//                                    if (this._selectedNodes.Keys.Contains(feature) == false)
//                                    {
//                                        this._selectedNodes.Add(feature, new List<List<int>>());
//                                    }
//                                    List<int> index = new List<int>();
//                                    index.Add(0);
//                                    index.Add(0);
//                                    this._selectedNodes[feature].Add(index);
//                                    this._selected = true;

//                                    //break;  //如果第一个点已经选择了，就直接跳出了switch
//                                }

//                                //首先判断是不是首尾相连的点
//                                if (feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].X != feature.BasicGeometry.Coordinates[0].X ||
//                                   feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].Y != feature.BasicGeometry.Coordinates[0].Y)
//                                {
//                                    if (env.Contains(feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1]) == true)
//                                    {
//                                        isIn = true;
//                                        if (this._selectedNodes.Keys.Contains(feature) == false)
//                                        {
//                                            this._selectedNodes.Add(feature, new List<List<int>>());
//                                        }
//                                        List<int> index = new List<int>();
//                                        index.Add(0);
//                                        index.Add(feature.BasicGeometry.Coordinates.Count - 1);
//                                        this._selectedNodes[feature].Add(index);
//                                        this._selected = true;
//                                    }
//                                }
//                                break;
//                            }
//                        case FeatureType.Polygon:
//                            {
//                                if (env.Contains((feature.BasicGeometry as Polygon).ExteriorRing.Coordinates[0]))
//                                {
//                                    isIn = true;
//                                    if (this._selectedNodes.Keys.Contains(feature) == false)
//                                    {
//                                        this._selectedNodes.Add(feature, new List<List<int>>());
//                                    }
//                                    List<int> index = new List<int>();
//                                    index.Add(0);
//                                    index.Add(0);
//                                    this._selectedNodes[feature].Add(index);
//                                    this._selected = true;

//                                    //break;  //如果第一个点已经选择了，就直接跳出了switch
//                                }

//                                //还要考虑是不是洞上的点
//                                //foreach (ILinearRing linearRing in (feature.BasicGeometry as Polygon).Holes)
//                                for (int i = 0; i < (feature.BasicGeometry as Polygon).Holes.Length; i++)
//                                {
//                                    if (env.Contains((feature.BasicGeometry as Polygon).Holes[i].Coordinates[0]))
//                                    {
//                                        isIn = true;
//                                        if (this._selectedNodes.Keys.Contains(feature) == false)
//                                        {
//                                            this._selectedNodes.Add(feature, new List<List<int>>());
//                                        }
//                                        List<int> index = new List<int>();
//                                        index.Add(i + 1);
//                                        index.Add(0);
//                                        this._selectedNodes[feature].Add(index);
//                                        this._selected = true;

//                                        //break;  //如果第一个点已经选择了，跳出循环

//                                    }
//                                }
//                                break;
//                            }
//                        default:
//                            {
//                                break;
//                            }
//                    }
//                    if (isIn == true && this._selectedFeatures.Contains(feature) == false)
//                        this._selectedFeatures.Add(feature);


//                }
//            }
//        }


//        private void SelectVertex(IEnvelope env)
//        {
//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                if (layer.DataSet.FeatureType == FeatureType.Line || layer.DataSet.FeatureType == FeatureType.Polygon)
//                {
//                    foreach (IFeature feature in layer.DataSet.Features)
//                    {
//                        if (feature.BasicGeometry.Coordinates.Count < 3) continue;

//                        if (feature.FeatureType == FeatureType.Polygon)  //多边形特殊对待
//                        {
//                            for (int i = 0; i < feature.NumGeometries; i++)
//                            {
//                                IBasicGeometry geometry = feature.GetBasicGeometryN(i);

//                                for (int j = 1; j < (geometry as Polygon).ExteriorRing.Coordinates.Count - 1; j++)
//                                {
//                                    if (env.Contains((geometry as Polygon).ExteriorRing.Coordinates[j]) == true)
//                                    {
//                                        if (this._selectedFeatures.Contains(feature) == false) this._selectedFeatures.Add(feature);
//                                        if (this._selectedVertexs.Keys.Contains(feature) == false)
//                                        {
//                                            this._selectedVertexs.Add(feature, new List<List<int>>());
//                                        }
//                                        List<int> index = new List<int>();
//                                        index.Add(0);
//                                        index.Add(j);
//                                        this._selectedVertexs[feature].Add(index); //.Clone() as Coordinate;
//                                        this._selected = true;
//                                        //if (this._isClick == true)
//                                        //{
//                                        //    return;  //如果是点选，只选一个就返回
//                                        //}
//                                    }
//                                }

//                                //foreach (ILinearRing linear in ((geometry as Polygon).Holes))
//                                for (int k = 0; k < (geometry as Polygon).Holes.Length; k++)
//                                {
//                                    for (int j = 1; j < (geometry as Polygon).Holes[k].Coordinates.Count - 1; j++)
//                                    {
//                                        if (env.Contains((geometry as Polygon).Holes[k].Coordinates[j]) == true)
//                                        {
//                                            if (this._selectedFeatures.Contains(feature) == false) this._selectedFeatures.Add(feature);
//                                            if (this._selectedVertexs.Keys.Contains(feature) == false)
//                                            {
//                                                this._selectedVertexs.Add(feature, new List<List<int>>());
//                                            }
//                                            List<int> index = new List<int>();
//                                            index.Add(k + 1);
//                                            index.Add(j);
//                                            this._selectedVertexs[feature].Add(index); //.Clone() as Coordinate;
//                                            this._selected = true;
//                                            //if (this._isClick == true)
//                                            //{
//                                            //    return;  //如果是点选，只选一个就返回
//                                            //}
//                                        }
//                                    }
//                                }

//                            }

//                        }
//                        else
//                        {
//                            for (int i = 1; i < feature.BasicGeometry.Coordinates.Count - 1; i++)
//                            {
//                                if (env.Contains(feature.BasicGeometry.Coordinates[i]) == true)
//                                {
//                                    if (this._selectedFeatures.Contains(feature) == false) this._selectedFeatures.Add(feature);
//                                    if (this._selectedVertexs.Keys.Contains(feature) == false)
//                                    {
//                                        this._selectedVertexs.Add(feature, new List<List<int>>());
//                                    }
//                                    List<int> index = new List<int>();
//                                    index.Add(0);
//                                    index.Add(i);
//                                    this._selectedVertexs[feature].Add(index); //.Clone() as Coordinate;
//                                    this._selected = true;

//                                    # region

//                                    //if (this._isClick == true)
//                                    //{
//                                    //    //如果是点选，还要考虑这个线是不是多边形线，而且这个多边形线是否转换成过多边形，如果转换过多边形，就要选择上对应的多边形的节点
//                                    //    ILinearRing linear = feature.BasicGeometry as LinearRing;
//                                    //    if (linear != null)
//                                    //    {

//                                    //        foreach (IFeatureLayer polyLayer in this.layerLst)
//                                    //        {
//                                    //            if (polyLayer.DataSet.FeatureType != FeatureType.Polygon) continue;
//                                    //            foreach (IFeature polyFeature in polyLayer.DataSet.Features)
//                                    //            {
//                                    //                //if (polyShp.Id != polyFeature.DataRow["id"].ToString()) continue;
//                                    //                for (int j = 1; j < (polyFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates.Count - 1; j++)
//                                    //                {
//                                    //                    if ((polyFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates[j].X != feature.BasicGeometry.Coordinates[i].X ||
//                                    //                        (polyFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates[j].Y != feature.BasicGeometry.Coordinates[i].Y) continue;
//                                    //                    if (this._selectedFeatures.Contains(polyFeature) == false) this._selectedFeatures.Add(polyFeature);
//                                    //                    if (this._selectedVertexs.Keys.Contains(polyFeature) == false)
//                                    //                    {
//                                    //                        this._selectedVertexs.Add(polyFeature, new List<List<int>>());
//                                    //                    }
//                                    //                    List<int> temIndex = new List<int>();
//                                    //                    temIndex.Add(0);
//                                    //                    temIndex.Add(j);
//                                    //                    this._selectedVertexs[polyFeature].Add(temIndex); //.Clone() as Coordinate;
//                                    //                    break;
//                                    //                }

//                                    //                //foreach (ILinearRing linearRing in (polyFeature.BasicGeometry as Polygon).Holes)
//                                    //                for (int k = 0; k < (polyFeature.BasicGeometry as Polygon).Holes.Length; k++)
//                                    //                {
//                                    //                    for (int j = 1; j < (polyFeature.BasicGeometry as Polygon).Holes[k].Coordinates.Count - 1; j++)
//                                    //                    {
//                                    //                        if ((polyFeature.BasicGeometry as Polygon).Holes[k].Coordinates[j].X != feature.BasicGeometry.Coordinates[i].X ||
//                                    //                            (polyFeature.BasicGeometry as Polygon).Holes[k].Coordinates[j].Y != feature.BasicGeometry.Coordinates[i].Y) continue;
//                                    //                        if (this._selectedFeatures.Contains(polyFeature) == false) this._selectedFeatures.Add(polyFeature);
//                                    //                        if (this._selectedVertexs.Keys.Contains(polyFeature) == false)
//                                    //                        {
//                                    //                            this._selectedVertexs.Add(polyFeature, new List<List<int>>());
//                                    //                        }
//                                    //                        List<int> temIndex = new List<int>();
//                                    //                        temIndex.Add(k + 1);
//                                    //                        temIndex.Add(j);

//                                    //                        this._selectedVertexs[polyFeature].Add(temIndex); //.Clone() as Coordinate;
//                                    //                        break;

//                                    //                    }
//                                    //                }
//                                    //            }


//                                    //        }
//                                    //    }


//                                    //    return;  //如果是点选，只选一个就返回
//                                    //}

//                                    # endregion
//                                }
//                            }
//                        }
//                    }
//                }
//            }
//        }


//        private void SelectLine(IEnvelope env)
//        {
//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                if (layer.DataSet.FeatureType != FeatureType.Line) continue;

//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    bool isAdd = false;
//                    if (feature.FeatureType == FeatureType.Line)
//                    {
//                        if (this._isClick == true)  //点选
//                        {
//                            if (feature.Intersects(env) == true)
//                            {
//                                isAdd = true;
//                            }
//                        }
//                        else  //框选
//                        {
//                            if (env.Contains(feature.Envelope) == true)
//                            {
//                                isAdd = true;
//                            }
//                        }
//                    }

//                    //新要求，多边形不选线了

//                    //if (feature.FeatureType == FeatureType.Polygon)
//                    //{
//                    //    if (this._isClick == true) //点选
//                    //    {
//                    //        //先把多边形转换成线
//                    //        Feature line = new Feature(FeatureType.Line, feature.BasicGeometry.Coordinates);
//                    //        if (line.Intersects(env) == true)
//                    //        {
//                    //            isAdd = true;                         
//                    //        }
//                    //    }
//                    //    else //框选
//                    //    {
//                    //        if (env.Contains(feature.Envelope) == true)
//                    //        {
//                    //            isAdd = true;                         
//                    //        }
//                    //    }
//                    //}

//                    if (isAdd == true)
//                    {
//                        if (this._selectedFeatures.Contains(feature) == false) this._selectedFeatures.Add(feature);
//                        this._selectedLines.Add(feature);
//                        this._selected = true;
//                        if (this._isClick == true)
//                        {
//                            return;  //如果是点选，只能选择一个，选择后返回就行了
//                        }
//                    }
//                }
//            }
//        }


//        private void SelectPolygon(IEnvelope env)
//        {
//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                if (layer.DataSet.FeatureType != FeatureType.Polygon) continue;

//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    bool isAdd = false;
//                    if (this._isClick == true)  //点选
//                    {
//                        if (feature.Intersects(env) == true)
//                        {
//                            isAdd = true;
//                        }
//                    }
//                    else //框选
//                    {
//                        if (env.Contains(feature.Envelope) == true)
//                        {
//                            isAdd = true;
//                        }
//                    }
//                    if (isAdd == true)
//                    {
//                        if (this._selectedFeatures.Contains(feature) == false) this._selectedFeatures.Add(feature);
//                        this._selectedPolygons.Add(feature);
//                        this._selected = true;
//                        if (this._isClick == true)
//                        {
//                            return;  //如果是点选，只能选择一个，选择后返回就行了
//                        }
//                    }

//                }
//            }
//        }

//        /// <summary>
//        /// delete键删除图形
//        /// </summary>
//        /// <param name="e"></param>
//        private void DeleteSelected(System.Windows.Forms.KeyEventArgs e)
//        {
//            if (e.KeyCode == System.Windows.Forms.Keys.Delete)
//            {
//                //这几个删除方法是必须按这个顺序的
//                this.DeleteNode();
//                this.DeleteLine();
//                this.DeletePolygon();
//                this.DeleteVertex();

//                this._selectedFeatures.Clear(); // = new List<IFeature>();
//                this._selectedLines.Clear();  // = new List<IFeature>();
//                this._selectedNodes.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//                this._selectedPolygons.Clear(); // = new List<IFeature>();
//                this._selectedVertexs.Clear(); // = new Dictionary<IFeature, List<List<int>>>();

//                Map.MapFrame.Initialize();
//                Map.Invalidate();
//            }
//        }

//        private void DeleteNode()
//        {
//            if (this._selectedNodes != null && this._selectedNodes.Count > 0)
//            {
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//                {
//                    if (feature.Key.FeatureType == FeatureType.Polygon)
//                    {
//                        foreach (IFeatureLayer layer in this.layerLst)
//                        {
//                            if (layer.DataSet.FeatureType != FeatureType.Polygon) continue;

//                            foreach (IFeature polyFeature in layer.DataSet.Features)
//                            {
//                                if (feature.Key == polyFeature)
//                                {
//                                    List<Coordinate> coors = new List<Coordinate>();
//                                    foreach (List<int> index in feature.Value)
//                                    {
//                                        if (index[0] == 0)
//                                        {
//                                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                                        }
//                                        else
//                                        {
//                                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                                        }
//                                    }

//                                    if (polyFeature.BasicGeometry.Coordinates[0].Equals2D(coors[0]) == true)
//                                    {
//                                        this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)feature.Key,false));
//                                        break;
//                                    }

//                                    for (int i = 0; i < (polyFeature.BasicGeometry as Polygon).Holes.Length; i++)
//                                    {
//                                        if ((polyFeature.BasicGeometry as Polygon).Holes[i].Coordinates[0].Equals2D(coors[0]))
//                                        {
//                                            IFeature newFeature = feature.Key.Clone() as IFeature;
//                                            List<ILinearRing> holes = (polyFeature.BasicGeometry as Polygon).Holes.CloneList();
//                                            holes.RemoveAt(i);
//                                            (newFeature.BasicGeometry as Polygon).Holes = holes.ToArray();
//                                            HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), newFeature as Feature,false);

//                                            this.InteractiveSystem.HGMSAskEditShape(args);
//                                            break;

//                                        }
//                                    }
//                                    break;
//                                }
//                            }
//                        }

//                    }
//                    else
//                    {
//                        this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)feature.Key,false));
//                    }

//                    if (this._selectedLines != null && this._selectedLines.Count > 0)
//                    {
//                        if (this._selectedLines.Contains(feature.Key)) this._selectedLines.Remove(feature.Key);
//                    }
//                    if (this._selectedPolygons != null && this._selectedPolygons.Count > 0)
//                    {
//                        if (this._selectedPolygons.Contains(feature.Key)) this._selectedPolygons.Remove(feature.Key);
//                    }

//                    if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//                    {
//                        if (this._selectedVertexs.Keys.Contains(feature.Key)) this._selectedVertexs.Remove(feature.Key);
//                    }
//                }
//            }
//        }

//        private void DeleteLine()
//        {
//            if (this._selectedLines != null && this._selectedLines.Count > 0)
//            {
//                foreach (IFeature feature in this._selectedLines)
//                {
//                    this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.DataRow["id"].ToString(), (Feature)feature,false));

//                    if (this._selectedPolygons != null && this._selectedPolygons.Count > 0)
//                    {
//                        if (this._selectedPolygons.Contains(feature)) this._selectedPolygons.Remove(feature);
//                    }

//                    if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//                    {
//                        if (this._selectedVertexs.Keys.Contains(feature)) this._selectedVertexs.Remove(feature);
//                    }
//                }

//            }
//        }

//        private void DeletePolygon()
//        {
//            if (this._selectedPolygons != null && this._selectedPolygons.Count > 0)
//            {
//                foreach (IFeature feature in this._selectedPolygons)
//                {
//                    foreach (IFeatureLayer layer in this.layerLst)
//                    {
//                        if (layer.DataSet.FeatureType != FeatureType.Polygon) continue;

//                        foreach (IFeature polyFeature in layer.DataSet.Features)
//                        {
//                            if (polyFeature.Equals(feature)) continue;

//                            List<Coordinate> coorLst = new List<Coordinate>();
//                            coorLst.AddRange((polyFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates);
//                            coorLst.RemoveAt(coorLst.Count - 1);
//                            IFeature temFeature = new Feature(polyFeature.FeatureType, coorLst.ToArray());

//                            if (temFeature.Contains(feature))
//                            {
//                                List<ILinearRing> linearLst = new List<ILinearRing>();

//                                foreach (ILinearRing linear in (polyFeature.BasicGeometry as Polygon).Holes)
//                                {
//                                    bool isSame = true;

//                                    for (int i = 0; i < Math.Min(linear.Coordinates.Count - 1, feature.BasicGeometry.Coordinates.Count - 1); i++)
//                                    {
//                                        if (linear.Coordinates[i].X != feature.BasicGeometry.Coordinates[i].X || linear.Coordinates[i].Y != feature.BasicGeometry.Coordinates[i].Y)
//                                        {
//                                            isSame = false;
//                                            break;
//                                        }
//                                    }
//                                    if (isSame == false)
//                                    {
//                                        if (linear.Coordinates.Equals(feature.BasicGeometry.Coordinates) == false)
//                                        {
//                                            linearLst.Add(linear);

//                                        }
//                                    }
//                                }

//                                Polygon polygon = new Polygon((polyFeature.BasicGeometry as Polygon).ExteriorRing.Clone() as LinearRing, linearLst.CloneList().ToArray());

//                                IFeature newPolyFeature = new Feature(polygon);

//                                HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, polyFeature.DataRow["id"].ToString(), newPolyFeature as Feature,false);
//                                this.InteractiveSystem.HGMSAskEditShape(args);

//                            }
//                        }
//                    }

//                    this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.DataRow["id"].ToString(), (Feature)feature,false));

//                    if (this._selectedVertexs != null && this._selectedVertexs.Count > 0)
//                    {
//                        if (this._selectedVertexs.Keys.Contains(feature)) this._selectedVertexs.Remove(feature);
//                    }
//                }
//            }
//        }

//        private void DeleteVertex()
//        {
//            if (this._selectedVertexs != null && this._selectedVertexs.Count > 0) //节点是一个特殊的存在，多边形有洞
//            {
//                foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//                {
//                    List<Coordinate> coors = new List<Coordinate>();
//                    foreach (List<int> index in feature.Value)
//                    {
//                        if (index[0] == 0)
//                        {
//                            coors.Add(feature.Key.BasicGeometry.Coordinates[index[1]]);
//                        }
//                        else
//                        {
//                            coors.Add((feature.Key.BasicGeometry as Polygon).Holes[index[0] - 1].Coordinates[index[1]]);
//                        }
//                    }

//                    List<Coordinate> coorLst = new List<Coordinate>();

//                    if (feature.Key.FeatureType == FeatureType.Polygon)  //如果是多边形，先判断外围，如果只剩下3个点了，则不能构成多边形了，直接删除……，再判断内部的洞，同理
//                    {
//                        foreach (Coordinate coor in (feature.Key.BasicGeometry as Polygon).ExteriorRing.Coordinates)
//                        {
//                            bool b = false; //标记，只要有一个已选的节点与feature的坐标相同，则新生成的图形不添加这个坐标
//                            foreach (Coordinate vertex in coors)
//                            {
//                                if (coor.X == vertex.X && coor.Y == vertex.Y)
//                                {
//                                    b = true; //图形坐标与所选节点相同
//                                    break;
//                                }
//                            }
//                            if (b == false)  //此坐标没有被选择
//                            {
//                                coorLst.Add(coor.Clone() as Coordinate);
//                            }
//                        }

//                        if (coorLst.Count < 4)  //小于4个点不能构成多边形直接删除
//                        {
//                            this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)feature.Key, false));
//                        }
//                        else   //编辑
//                        {
//                            IFeature newFeature = feature.Key.Clone() as IFeature;
//                            (newFeature.BasicGeometry as Polygon).ExteriorRing.Coordinates = coorLst.CloneList(); //外围 的坐标

//                            //判断洞
//                            List<ILinearRing> holes = (newFeature.BasicGeometry as Polygon).Holes.CloneList();

//                            for (int i = 0; i < (newFeature.BasicGeometry as Polygon).Holes.Length; i++)
//                            {
//                                for (int j = 0; j < (newFeature.BasicGeometry as Polygon).Holes[i].Coordinates.Count; j++)
//                                {
//                                    foreach (Coordinate vertex in coors)
//                                    {
//                                        if ((newFeature.BasicGeometry as Polygon).Holes[i].Coordinates[j].X == vertex.X && (newFeature.BasicGeometry as Polygon).Holes[i].Coordinates[j].Y == vertex.Y)
//                                        {
//                                            holes[i].Coordinates.RemoveAt(j);
//                                        }
//                                    }
//                                }
//                            }

//                            List<ILinearRing> newHoles = new List<ILinearRing>();

//                            foreach (ILinearRing hole in holes)
//                            {
//                                if (hole.Coordinates.Count > 3)
//                                {
//                                    newHoles.Add(hole);
//                                }
//                            }

//                            (newFeature.BasicGeometry as Polygon).Holes = newHoles.ToArray();

//                            this.InteractiveSystem.HGMSAskEditShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)newFeature, false));
//                            feature.Key.UpdateEnvelope();  //更新还是写在这吧                 
//                        }
//                    }
//                    else
//                    {
//                        foreach (Coordinate coor in feature.Key.BasicGeometry.Coordinates)
//                        {
//                            bool b = false; //标记，只要有一个已选的节点与feature的坐标相同，则新生成的图形不添加这个坐标
//                            foreach (Coordinate vertex in coors)
//                            {
//                                if (coor.X == vertex.X && coor.Y == vertex.Y)
//                                {
//                                    b = true; //图形坐标与所选节点相同
//                                    break;
//                                }
//                            }
//                            if (b == false)  //此坐标没有被选择
//                            {
//                                coorLst.Add(coor);
//                            }
//                        }

//                        //ILinearRing linear = feature.Key.BasicGeometry as ILinearRing;

//                        //if (linear != null && coorLst.Count < 4)  //如果是多边形线并且坐标个数小于3个

//                        LineShape lineShp = (this.InteractiveSystem.CurrentLayer as VectorLayer).GetShape(feature.Key.DataRow["id"].ToString()) as LineShape;

//                        if (lineShp.IsEnClosed && coorLst.Count < 4)  //如果是多边形线并且坐标个数小于3个
//                        {
//                            this.InteractiveSystem.HGMSAskDeleteShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)feature.Key, false));
//                        }
//                        else
//                        {
//                            IFeature newFeature = null;
//                            if (lineShp.IsEnClosed)
//                            {
//                                ILinearRing linear = new LinearRing(coorLst.ToArray());
//                                newFeature = new Feature(linear);
//                            }
//                            else
//                            {
//                                newFeature = new Feature(feature.Key.FeatureType, coorLst.ToArray());
//                            }
//                            this.InteractiveSystem.HGMSAskEditShape(new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.Key.DataRow["id"].ToString(), (Feature)newFeature, false));
//                            feature.Key.UpdateEnvelope();  //更新还是写在这吧    
//                        }
//                    }
//                }
//            }
//        }



//        /// <summary>
//        /// //确定哪些点跟要移动的点有关系
//        /// </summary>
//        private void CheckForVertexDrag()
//        {
//            if (this._selectedFeatures == null || this._selectedFeatures.Count < 1) return;
//            if (this._dragPoint == null) return;
//            this._dragFeatures = new List<IFeature>();
//            this._nextPoints = new List<Coordinate>();
//            foreach (IFeature feature in this._selectedFeatures)
//            {
//                switch (feature.FeatureType)
//                {
//                    case FeatureType.Point:
//                        if (feature.BasicGeometry.Coordinates[0].X == this._dragPoint.X && feature.BasicGeometry.Coordinates[0].Y == this._dragPoint.Y)
//                        {
//                            this._dragFeatures.Add(feature);
//                            continue;
//                        }
//                        break;
//                    case FeatureType.Line:

//                        for (int i = 0; i < feature.NumGeometries; i++)
//                        {
//                            IBasicGeometry geometry = feature.GetBasicGeometryN(i);
//                            IList<Coordinate> coors = geometry.Coordinates;

//                            for (int j = 0; j < coors.Count; j++)
//                            {
//                                Coordinate c = coors[j];

//                                Rectangle mouseRect;
//                                IEnvelope env;


//                                //点选范围
//                                mouseRect = new Rectangle(this.Map.ProjToPixel(this._dragPoint).X - 3, this.Map.ProjToPixel(this._dragPoint).Y - 3, 6, 6);
//                                env = Map.PixelToProj(mouseRect).ToEnvelope();

//                                //if (c.X == this._dragPoint.X && c.Y == this._dragPoint.Y)
//                                if (env.Contains(c))
//                                {
//                                    if (j == 0)
//                                    {
//                                        if (c.X == coors[coors.Count - 1].X && c.Y == coors[coors.Count - 1].Y)  //首尾相连的线
//                                        {
//                                            this._nextPoints.Add(coors[coors.Count - 2]);
//                                        }
//                                        this._nextPoints.Add(coors[1]);
//                                    }
//                                    else if (j == coors.Count - 1)
//                                    {
//                                        if (c.X != coors[0].X || c.Y != coors[0].Y)  //首尾相连的线
//                                        {
//                                            this._nextPoints.Add(coors[coors.Count - 2]);
//                                        }
//                                    }
//                                    else
//                                    {
//                                        this._nextPoints.Add(coors[j - 1]);
//                                        this._nextPoints.Add(coors[j + 1]);
//                                    }
//                                    if (this._dragFeatures.Contains(feature) == false)
//                                    {
//                                        this._dragFeatures.Add(feature);
//                                    }
//                                    Map.Invalidate();
//                                    //break;
//                                }
//                            }
//                        }

//                        break;
//                    case FeatureType.Polygon:

//                        for (int i = 0; i < feature.NumGeometries; i++)
//                        {
//                            IBasicGeometry geometry = feature.GetBasicGeometryN(i);

//                            IList<Coordinate> coors = (geometry as Polygon).ExteriorRing.Coordinates;

//                            for (int j = 0; j < coors.Count; j++)
//                            {
//                                Coordinate c = coors[j];

//                                if (c.X == this._dragPoint.X && c.Y == this._dragPoint.Y)
//                                {
//                                    if (j == 0 || j == coors.Count - 1)
//                                    {
//                                        this._nextPoints.Add(coors[coors.Count - 2]);
//                                        this._nextPoints.Add(coors[1]);
//                                    }
//                                    else
//                                    {
//                                        this._nextPoints.Add(coors[j - 1]);
//                                        this._nextPoints.Add(coors[j + 1]);
//                                    }
//                                    if (this._dragFeatures.Contains(feature) == false)
//                                    {
//                                        this._dragFeatures.Add(feature);
//                                    }
//                                    Map.Invalidate();
//                                    //break;
//                                }
//                            }


//                            foreach (LinearRing linear in (geometry as Polygon).Holes)
//                            {
//                                coors = linear.Coordinates;

//                                for (int j = 0; j < coors.Count; j++)
//                                {
//                                    Coordinate c = coors[j];
//                                    if (c.X == this._dragPoint.X && c.Y == this._dragPoint.Y)
//                                    {
//                                        if (j == 0 || j == coors.Count - 1)
//                                        {
//                                            this._nextPoints.Add(coors[coors.Count - 2]);
//                                            this._nextPoints.Add(coors[1]);
//                                        }
//                                        else
//                                        {
//                                            this._nextPoints.Add(coors[j - 1]);
//                                            this._nextPoints.Add(coors[j + 1]);
//                                        }
//                                        if (this._dragFeatures.Contains(feature) == false)
//                                        {
//                                            this._dragFeatures.Add(feature);
//                                        }
//                                        Map.Invalidate();
//                                        //break;
//                                    }

//                                }
//                            }

//                        }

//                        break;
//                    default:
//                        break;
//                }
//            }
//        }

//        /// <summary>
//        /// 插入顶点
//        /// </summary>
//        /// <param name="position"></param>
//        private void InsertVertex(Coordinate position)
//        {
//            Rectangle rect = new Rectangle(Map.ProjToPixel(position).X - 3, Map.ProjToPixel(position).Y - 3, 6, 6);
//            IEnvelope env = Map.PixelToProj(rect).ToEnvelope(); 

//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                if (layer.DataSet.FeatureType != FeatureType.Line) continue;

//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    if (feature.Intersects(env))
//                    {
//                        //编辑
//                        for (int i = 0; i < feature.BasicGeometry.Coordinates.Count - 1; i++)
//                        {
//                            List<Coordinate> coorLst = new List<Coordinate>();
//                            coorLst.Add(new Coordinate(feature.BasicGeometry.Coordinates[i].X, feature.BasicGeometry.Coordinates[i].Y));
//                            coorLst.Add(new Coordinate(feature.BasicGeometry.Coordinates[i + 1].X, feature.BasicGeometry.Coordinates[i + 1].Y));

//                            IFeature temFeature = new Feature(FeatureType.Line, coorLst.ToArray());

//                            if (temFeature.Intersects(env))
//                            {
//                                coorLst = new List<Coordinate>();
//                                coorLst.AddRange(feature.BasicGeometry.Coordinates.CloneList());
//                                coorLst.Insert(i + 1, position.Clone() as Coordinate);

//                                LineShape lineShp = (this.InteractiveSystem.CurrentLayer as VectorLayer).GetShape(feature.DataRow["id"].ToString()) as LineShape;

//                                IFeature newFeature = null;

//                                if (lineShp.IsEnClosed)
//                                {
//                                    ILinearRing linear = new LinearRing(coorLst.ToArray());
//                                    newFeature = new Feature(linear);
//                                }
//                                else
//                                {                                                                        
//                                    newFeature = new Feature(FeatureType.Line, coorLst.ToArray());
//                                }

//                                HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, feature.DataRow["id"].ToString(), newFeature as Feature, true);

//                                this.InteractiveSystem.HGMSAskEditShape(args);

//                                break;
//                            }
//                        }

//                        break;
//                    }
//                }

//            }
//        }

//        # endregion



//        # region 线的裁剪与合并

//        /// <summary>
//        /// 根据所选的节点切分线
//        /// </summary>
//        public void ClipFeatureByVertex()
//        {
//            //这个方法是vertex->node的方法
//            //即将一条线在所选的vertex处切分为两条线

//            List<Feature> featureLst = new List<Feature>();

//            foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedVertexs)
//            {
//                if (feature.Key.FeatureType != FeatureType.Line) continue;

//                featureLst = new List<Feature>();
//                //this.ClipFeature(feature, ref featureLst);
//                featureLst = this.ClipFeature(feature);
//                if (featureLst.Count > 1)
//                {
//                    List<string> featureid = new List<string>();
//                    featureid.Add(feature.Key.DataRow["id"].ToString());

//                    string groupName = feature.Key.DataRow["group"].ToString();

//                    HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs(groupName, this.InteractiveSystem.CurrentLayer.Id, featureid, featureLst, false);

//                    this.InteractiveSystem.HGMSAskUnionOrSplitShape(args);
//                }
//            }
//            this._selectedFeatures.Clear(); // = new List<IFeature>();
//            this._selectedLines.Clear();  // = new List<IFeature>();
//            this._selectedNodes.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//            this._selectedPolygons.Clear(); // = new List<IFeature>();
//            this._selectedVertexs.Clear(); // = new Dictionary<IFeature, List<List<int>>>();

//            Map.MapFrame.Initialize();
//            Map.Invalidate();

//        }

//        private List<Feature> ClipFeature(KeyValuePair<IFeature, List<List<int>>> feature)
//        {
//            List<int> index = new List<int>();
//            for (int k = 0; k < feature.Value.Count; k++)
//            {
//                index.Add(feature.Value[k][1]);
//            }
//            //对存的坐标点的位置进行排序
//            for (int i = 0; i < index.Count - 1; i++)
//            {
//                for (int j = i + 1; j < index.Count; j++)
//                {
//                    if (index[i] > index[j])
//                    {
//                        int value = index[i];
//                        index[i] = index[j];
//                        index[j] = index[i];
//                    }
//                }
//            }

//            List<Feature> featureLst = new List<Feature>();

//            List<Coordinate> coorLst = new List<Coordinate>();
//            Feature fea = null;

//            for (int i = 0; i < index.Count; i++)
//            {
//                coorLst = new List<Coordinate>();
//                if (i == 0)
//                {
//                    for (int j = 0; j < index[i] + 1; j++)
//                    {
//                        coorLst.Add(feature.Key.BasicGeometry.Coordinates[j].Clone() as Coordinate);
//                    }
//                }
//                else
//                {
//                    for (int j = index[i - 1]; j < index[i] + 1; j++)
//                    {
//                        coorLst.Add(feature.Key.BasicGeometry.Coordinates[j].Clone() as Coordinate);
//                    }
//                }
//                fea = new Feature(FeatureType.Line, coorLst.ToArray());
//                featureLst.Add(fea);
//            }
//            coorLst = new List<Coordinate>();
//            for (int j = index[index.Count - 1]; j < feature.Key.BasicGeometry.Coordinates.Count; j++)
//            {
//                coorLst.Add(feature.Key.BasicGeometry.Coordinates[j].Clone() as Coordinate);
//            }
//            fea = new Feature(FeatureType.Line, coorLst.ToArray());
//            featureLst.Add(fea);

//            return featureLst;
//        }


//        private void ClipFeature(KeyValuePair<IFeature, List<List<int>>> feature, ref  List<Feature> featureLst)
//        {

//            for (int k = 0; k < feature.Value.Count; k++)
//            {
//                Coordinate vertex = feature.Key.BasicGeometry.Coordinates[feature.Value[k][1]];
//                for (int i = 1; i < feature.Key.BasicGeometry.Coordinates.Count - 1; i++)
//                {
//                    if (feature.Key.BasicGeometry.Coordinates[i].X == vertex.X && feature.Key.BasicGeometry.Coordinates[i].Y == vertex.Y)
//                    {
//                        List<List<int>> vertexs = new List<List<int>>();
//                        for (int n = k + 1; n < feature.Value.Count; n++)
//                        {
//                            vertexs.Add(feature.Value[n]);
//                        }


//                        List<Coordinate> coorLst = new List<Coordinate>();
//                        for (int j = 0; j < i + 1; j++)
//                        {
//                            Coordinate c = new Coordinate(feature.Key.BasicGeometry.Coordinates[j].X, feature.Key.BasicGeometry.Coordinates[j].Y);
//                            coorLst.Add(c);
//                        }
//                        IFeature fea1 = new Feature(feature.Key.FeatureType, coorLst.ToArray());
//                        KeyValuePair<IFeature, List<List<int>>> feature1 = new KeyValuePair<IFeature, List<List<int>>>(fea1, vertexs);
//                        this.ClipFeature(feature1, ref featureLst);

//                        coorLst = new List<Coordinate>();
//                        for (int j = i; j < feature.Key.BasicGeometry.Coordinates.Count; j++)
//                        {
//                            Coordinate c = new Coordinate(feature.Key.BasicGeometry.Coordinates[j].X, feature.Key.BasicGeometry.Coordinates[j].Y);
//                            coorLst.Add(c);
//                        }

//                        IFeature fea2 = new Feature(feature.Key.FeatureType, coorLst.ToArray());
//                        KeyValuePair<IFeature, List<List<int>>> feature2 = new KeyValuePair<IFeature, List<List<int>>>(fea2, vertexs);
//                        this.ClipFeature(feature2, ref featureLst);

//                        return;
//                    }
//                }

//            }

//            featureLst.Add(feature.Key as Feature);
//        }


//        /// <summary>
//        /// 根据所选的端点，如果两条线的端点重合，合并成一条线
//        /// </summary>
//        public void UnionFeatureByNode()
//        {
//            //=================================================================================================================================//
//            //下面的代码是先筛选this ._selectedNodes，因为两个端点只能是相近，不可能完全相同

//            List<Coordinate> nodes = new List<Coordinate>();

//            foreach (KeyValuePair<IFeature, List<List<int>>> feature in this._selectedNodes)
//            {
//                List<Coordinate> coors = new List<Coordinate>();
//                foreach (List<int> ptIndex in feature.Value)
//                {
//                    if (ptIndex[0] == 0)
//                    {
//                        coors.Add(feature.Key.BasicGeometry.Coordinates[ptIndex[1]]);
//                    }
//                    else
//                    {
//                        coors.Add((feature.Key.BasicGeometry as Polygon).Holes[ptIndex[0] - 1].Coordinates[ptIndex[1]]);
//                    }
//                }

//                nodes.AddRange(coors);
//            }

//            List<Coordinate> selectedNodes = new List<Coordinate>();
//            List<int> index = new List<int>();
//            for (int i = 0; i < nodes.Count - 1; i++)
//            {
//                Rectangle Rect = new Rectangle(this.Map.ProjToPixel(nodes[i]).X - 3, this.Map.ProjToPixel(nodes[i]).Y - 3, 6, 6);
//                IEnvelope env = Map.PixelToProj(Rect).ToEnvelope();

//                for (int j = i + 1; j < this._selectedNodes.Count; j++)
//                {
//                    if (env.Contains(nodes[j]))
//                    {
//                        index.Add(j);
//                    }
//                }
//            }

//            for (int i = 0; i < this._selectedNodes.Count; i++)
//            {
//                if (index.Contains(i) == false)
//                {
//                    selectedNodes.Add(nodes[i]);
//                }
//            }

//            this._selectedNodes.Clear(); // = new Dictionary<IFeature, List<List<int>>>();   //清空

//            //===============================================================================================================================//

//            List<Coordinate> usedNode = new List<Coordinate>();

//            foreach (Coordinate node in selectedNodes)
//            {
//                List<string> usedId = new List<string>();

//                if (usedNode.Contains(node)) continue;
//                usedNode.Add(node);

//                Rectangle Rect = new Rectangle(this.Map.ProjToPixel(node).X - 3, this.Map.ProjToPixel(node).Y - 3, 6, 6);
//                IEnvelope env = Map.PixelToProj(Rect).ToEnvelope();

//                List<IFeature> feas = new List<IFeature>();
//                foreach (IFeature feature in this._selectedFeatures)
//                {
//                    if (feature.FeatureType != FeatureType.Line) continue;

//                    if (env.Contains(feature.BasicGeometry.Coordinates[0]))
//                    {
//                        //如果是首尾相连的多边形线则不合并
//                        if (feature.BasicGeometry.Coordinates[0].X == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].X && feature.BasicGeometry.Coordinates[0].Y == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].Y)
//                        {
//                            continue;
//                        }
//                        if (feas.Contains(feature) == false)
//                        {
//                            usedId.Add(feature.DataRow["id"].ToString());

//                            feas.Add(feature);
//                            continue;
//                        }

//                    }
//                    if (env.Contains(feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1]))
//                    {
//                        if (feas.Contains(feature) == false)
//                        {
//                            usedId.Add(feature.DataRow["id"].ToString());

//                            feas.Add(feature);
//                        }
//                    }
//                }

//                //只有两个图形相连时才触发合并事件
//                if (feas.Count == 2)
//                {
//                    List<string> featureId = new List<string>();
//                    featureId.Add(feas[0].DataRow["id"].ToString());
//                    featureId.Add(feas[1].DataRow["id"].ToString());

//                    List<Coordinate> coorLst = new List<Coordinate>();
//                    if (env.Contains(feas[0].BasicGeometry.Coordinates[0]) && env.Contains(feas[1].BasicGeometry.Coordinates[0]))
//                    {
//                        coorLst.AddRange(feas[0].BasicGeometry.Coordinates.Reverse().ToArray());
//                        coorLst.RemoveAt(coorLst.Count - 1);
//                        coorLst.AddRange(feas[1].BasicGeometry.Coordinates.ToArray());
//                    }
//                    else if (env.Contains(feas[0].BasicGeometry.Coordinates[0]) && env.Contains(feas[1].BasicGeometry.Coordinates[feas[1].BasicGeometry.Coordinates.Count - 1]))
//                    {
//                        coorLst.AddRange(feas[1].BasicGeometry.Coordinates.ToArray());
//                        coorLst.RemoveAt(coorLst.Count - 1);
//                        coorLst.AddRange(feas[0].BasicGeometry.Coordinates.ToArray());
//                    }
//                    else if (env.Contains(feas[0].BasicGeometry.Coordinates[feas[0].BasicGeometry.Coordinates.Count - 1]) && env.Contains(feas[1].BasicGeometry.Coordinates[0]))
//                    {
//                        coorLst.AddRange(feas[0].BasicGeometry.Coordinates.ToArray());
//                        coorLst.RemoveAt(coorLst.Count - 1);
//                        coorLst.AddRange(feas[1].BasicGeometry.Coordinates.ToArray());
//                    }
//                    else if (env.Contains(feas[0].BasicGeometry.Coordinates[feas[0].BasicGeometry.Coordinates.Count - 1]) && env.Contains(feas[1].BasicGeometry.Coordinates[feas[1].BasicGeometry.Coordinates.Count - 1]))
//                    {
//                        coorLst.AddRange(feas[0].BasicGeometry.Coordinates.ToArray());
//                        coorLst.RemoveAt(coorLst.Count - 1);
//                        coorLst.AddRange(feas[1].BasicGeometry.Coordinates.Reverse().ToArray());
//                    }


//                    bool isContain = true;


//                    while (isContain == true)// this._selectedNodes.Contains(coorLst[coorLst.Count - 1]) && (usedNode.Contains(coorLst[0]) == false && usedNode.Contains(coorLst[coorLst.Count - 1]) == false))
//                    {
//                        Rectangle Rect1;
//                        IEnvelope env1 = null;

//                        isContain = false;
//                        foreach (Coordinate c in selectedNodes)
//                        {
//                            Rect1 = new Rectangle(this.Map.ProjToPixel(c).X - 3, this.Map.ProjToPixel(c).Y - 3, 6, 6);
//                            env1 = this.Map.PixelToProj(Rect1).ToEnvelope();
//                            //env1.ExpandBy(3);
//                            if (env1.Contains(coorLst[coorLst.Count - 1]))
//                            {
//                                usedNode.Add(c);
//                                if (env1.Contains(coorLst[0])) break;
//                                isContain = true;

//                                break;
//                            }
//                        }

//                        if (isContain == false)
//                        {
//                            break;
//                        }



//                        List<Feature> twoFeature = new List<Feature>();

//                        foreach (IFeature feature in this._selectedFeatures)
//                        {
//                            if (feature.FeatureType != FeatureType.Line) continue;

//                            if (env1.Contains(feature.BasicGeometry.Coordinates[0]))
//                            {
//                                //如果是首尾相边的多边形线则不合并
//                                if (feature.BasicGeometry.Coordinates[0].X == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].X && feature.BasicGeometry.Coordinates[0].Y == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].Y)
//                                {
//                                    continue;
//                                }
//                                if (twoFeature.Contains(feature) == false)
//                                {
//                                    twoFeature.Add(feature as Feature);
//                                    continue;
//                                }

//                            }
//                            if (env1.Contains(feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1]))
//                            {
//                                if (twoFeature.Contains(feature) == false)
//                                {
//                                    twoFeature.Add(feature as Feature);
//                                }
//                            }
//                        }

//                        if (twoFeature.Count != 2) break;

//                        if (usedId.Contains(twoFeature[0].DataRow["id"].ToString()))
//                        {
//                            coorLst.RemoveAt(coorLst.Count - 1);
//                            if (env1.Contains(twoFeature[1].BasicGeometry.Coordinates[0]))
//                            {
//                                coorLst.AddRange(twoFeature[1].BasicGeometry.Coordinates);
//                            }
//                            else
//                            {
//                                coorLst.AddRange(twoFeature[1].BasicGeometry.Coordinates.Reverse());
//                            }
//                            usedId.Add(twoFeature[1].DataRow["id"].ToString());
//                            featureId.Add(twoFeature[1].DataRow["id"].ToString());
//                        }
//                        else
//                        {
//                            coorLst.RemoveAt(coorLst.Count - 1);
//                            if (env1.Contains(twoFeature[0].BasicGeometry.Coordinates[0]))
//                            {
//                                coorLst.AddRange(twoFeature[0].BasicGeometry.Coordinates);
//                            }
//                            else
//                            {
//                                coorLst.AddRange(twoFeature[0].BasicGeometry.Coordinates.Reverse());
//                            }
//                            usedId.Add(twoFeature[0].DataRow["id"].ToString());
//                            featureId.Add(twoFeature[0].DataRow["id"].ToString());
//                        }


//                    }

//                    isContain = true;

//                    while (isContain == true) // this._selectedNodes.Contains(coorLst[0]) && (usedNode.Contains(coorLst[0]) == false && usedNode.Contains(coorLst[coorLst.Count - 1]) == false) )
//                    {
//                        Rectangle Rect1;
//                        IEnvelope env1 = null;

//                        isContain = false;
//                        foreach (Coordinate c in selectedNodes)
//                        {
//                            Rect1 = new Rectangle(this.Map.ProjToPixel(c).X - 3, this.Map.ProjToPixel(c).Y - 3, 6, 6);
//                            env1 = this.Map.PixelToProj(Rect1).ToEnvelope();
//                            //env1.ExpandBy(3);
//                            if (env1.Contains(coorLst[0]))
//                            {
//                                usedNode.Add(c);
//                                if (env1.Contains(coorLst[coorLst.Count - 1])) break;
//                                isContain = true;

//                                break;
//                            }
//                        }

//                        if (isContain == false)
//                        {
//                            break;
//                        }



//                        List<Feature> twoFeature = new List<Feature>();

//                        foreach (IFeature feature in this._selectedFeatures)
//                        {
//                            if (feature.FeatureType != FeatureType.Line) continue;

//                            if (env1.Contains(feature.BasicGeometry.Coordinates[0]))
//                            {
//                                //如果是首尾相边的多边形线则不合并
//                                if (feature.BasicGeometry.Coordinates[0].X == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].X && feature.BasicGeometry.Coordinates[0].Y == feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1].Y)
//                                {
//                                    continue;
//                                }
//                                if (twoFeature.Contains(feature) == false)
//                                {
//                                    twoFeature.Add(feature as Feature);
//                                    continue;
//                                }

//                            }
//                            if (env1.Contains(feature.BasicGeometry.Coordinates[feature.BasicGeometry.Coordinates.Count - 1]))
//                            {
//                                if (twoFeature.Contains(feature) == false)
//                                {
//                                    twoFeature.Add(feature as Feature);
//                                }
//                            }
//                        }

//                        if (twoFeature.Count != 2) break;

//                        if (usedId.Contains(twoFeature[0].DataRow["id"].ToString()))
//                        {
//                            coorLst.RemoveAt(0);
//                            if (env1.Contains(twoFeature[1].BasicGeometry.Coordinates[0]))
//                            {
//                                coorLst.InsertRange(0, twoFeature[1].BasicGeometry.Coordinates.Reverse());
//                            }
//                            else
//                            {
//                                coorLst.InsertRange(0, twoFeature[1].BasicGeometry.Coordinates);
//                            }
//                            usedId.Add(twoFeature[1].DataRow["id"].ToString());
//                            featureId.Add(twoFeature[1].DataRow["id"].ToString());
//                        }
//                        else
//                        {
//                            coorLst.RemoveAt(0);
//                            if (env1.Contains(twoFeature[0].BasicGeometry.Coordinates[0]))
//                            {
//                                coorLst.InsertRange(0, twoFeature[0].BasicGeometry.Coordinates.Reverse());
//                            }
//                            else
//                            {
//                                coorLst.InsertRange(0, twoFeature[0].BasicGeometry.Coordinates);
//                            }
//                            usedId.Add(twoFeature[0].DataRow["id"].ToString());
//                            featureId.Add(twoFeature[0].DataRow["id"].ToString());
//                        }

//                    }

//                    Feature newFea = null;

//                    Rectangle R = new Rectangle(this.Map.ProjToPixel(coorLst[0]).X - 3, this.Map.ProjToPixel(coorLst[0]).Y - 3, 6, 6);
//                    IEnvelope E = this.Map.PixelToProj(R).ToEnvelope();


//                    if (coorLst[0].X == coorLst[coorLst.Count - 1].X && coorLst[0].Y == coorLst[coorLst.Count - 1].Y)
//                    {
//                        ILinearRing linear = new LinearRing(coorLst.ToArray());
//                        newFea = new Feature(linear);
//                    }
//                    else if ((selectedNodes.Contains(coorLst[0]) || selectedNodes.Contains(coorLst[coorLst.Count - 1])) && E.Contains(coorLst[coorLst.Count - 1]))
//                    {
//                        ILinearRing linear = new LinearRing(coorLst.ToArray());
//                        newFea = new Feature(linear);
//                    }
//                    else
//                    {
//                        newFea = new Feature(feas[0].FeatureType, coorLst.ToArray());
//                    }

//                    List<Feature> features = new List<Feature>();
//                    //features.Add(feas[0] as Feature);
//                    features.Add(newFea);

//                    HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs("", this.InteractiveSystem.CurrentLayer.Id, featureId, features, true);

//                    this.InteractiveSystem.HGMSAskUnionOrSplitShape(args);
//                }

//            }

//            this._selectedFeatures.Clear(); // = new List<IFeature>();
//            this._selectedLines.Clear();  // = new List<IFeature>();
//            this._selectedNodes.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//            this._selectedPolygons.Clear(); // = new List<IFeature>();
//            this._selectedVertexs.Clear(); // = new Dictionary<IFeature, List<List<int>>>();
//        }

//        # endregion



//        # region 多边形线转多边形的操做

//        /// <summary>
//        /// 线转多边形
//        /// </summary>
//        private void LineToPolygon()
//        {
//            //多边形线转多边形的时候还要考虑原本就存在的多边形
//            //思路：每转换一个多边形，遍历所有已存在的多边形，判断相互关系，添加新的，修改原来的。图层刷新

//            foreach (IFeatureLayer layer in this.layerLst)
//            {
//                if (layer.DataSet.FeatureType != FeatureType.Line) continue;

//                foreach (IFeature feature in layer.DataSet.Features)
//                {
//                    //查找对应的自定义shp
//                    LineShape line = (this.InteractiveSystem.CurrentLayer as VectorLayer).GetShape(feature.DataRow["id"].ToString()) as LineShape;

//                    if (line.IsEnClosed == true)
//                    {
//                        bool b = (this.InteractiveSystem.CurrentLayer as VectorLayer).ExistSameKeyShp(line.PolyKey);  //判断多边形线是否已转换
//                        if (b == false)
//                        {
//                            IFeature newPolygon = new Feature(FeatureType.Polygon, feature.BasicGeometry.Coordinates.CloneList());

//                            //遍历所有已存在的多边形
//                            //先判断新图形包含哪此图形，对新图形裁剪
//                            foreach (IFeatureLayer polyLayer in this.layerLst)
//                            {
//                                if (polyLayer.DataSet.FeatureType != FeatureType.Polygon) continue;

//                                //判断相互关系
//                                foreach (IFeature polyFeature in polyLayer.DataSet.Features)
//                                {
//                                    if (newPolygon.Contains(polyFeature))
//                                    {
//                                        newPolygon = newPolygon.Difference(polyFeature);

//                                        List<Coordinate> coorLst = new List<Coordinate>();
//                                        coorLst.AddRange((newPolygon.BasicGeometry as Polygon).ExteriorRing.Coordinates);
//                                        coorLst.RemoveAt(coorLst.Count - 1);


//                                        List<Coordinate[]> holes = new List<Coordinate[]>();
//                                        foreach (ILinearRing linear in (newPolygon as Polygon).Holes)
//                                        {
//                                            List<Coordinate> hole = new List<Coordinate>();
//                                            hole.AddRange(linear.Coordinates);
//                                            hole.RemoveAt(hole.Count - 1);
//                                            holes.Add(hole.ToArray());
//                                        }

//                                        this.InteractiveSystem.AskAddConvertedPolyShape("", line.PolyKey, coorLst.ToArray(), holes);

//                                    }
//                                }
//                            }

//                            //再判断哪些图形包含新图形（裁剪后的）,再编辑旧图形
//                            foreach (IFeatureLayer polyLayer in this.layerLst)
//                            {
//                                foreach (IFeature polyFeature in polyLayer.DataSet.Features)
//                                {
//                                    if (polyFeature.Contains(newPolygon))
//                                    {
//                                        //添加新生成的
//                                        List<Coordinate> coorLst = new List<Coordinate>();
//                                        coorLst.AddRange(newPolygon.BasicGeometry.Coordinates);
//                                        coorLst.RemoveAt(coorLst.Count - 1);
//                                        this.InteractiveSystem.AskAddConvertedPolyShape("", line.PolyKey, newPolygon.BasicGeometry.Coordinates.ToArray(), null);
//                                        //修改旧的
//                                        IFeature oldFeature = polyFeature.Difference(newPolygon);

//                                        //修改事件
//                                        HGMSSelectMFEventArgs args = new HGMSSelectMFEventArgs(this.InteractiveSystem.CurrentLayer.Id, polyFeature.DataRow["id"].ToString(), oldFeature as Feature,true);
//                                        this.InteractiveSystem.HGMSAskEditShape(args);

//                                    }
//                                }
//                            }


//                        }
//                    }
//                }
//            }
//        }


//        # endregion


//    }
//}
